<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    /**
   * @param {string[]} words
   * @return {string[]}
   */
    var removeAnagrams = function (words) {
      let lastStr = ''
      return words.filter(word => {
        const cur = word.split('').sort().join('')
        if (lastStr !== cur) {
          return lastStr = cur
        }
      })
    };
    console.log(removeAnagrams(["abba", "baba", "bbaa", "cd", "cd"]))
  </script>
</body>

</html>